package com.example.prjbackend.controller;

import com.example.prjbackend.common.core.controller.BaseController;
import com.example.prjbackend.common.core.domain.AjaxResult;
import com.example.prjbackend.common.core.page.TableDataInfo;
import com.example.prjbackend.domain.Bumen;
import com.example.prjbackend.service.BumenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/bumen")
public class BumenController extends BaseController {
    @Autowired
    BumenService bumenService;

    @PostMapping
    public AjaxResult add(@RequestBody Bumen bumen){
       return toAjax(bumenService.add(bumen));
    }

    @GetMapping
    public TableDataInfo list(Bumen bumen){
        startPage();
        List<Bumen> list=bumenService.list(bumen);
        return getDataByPage(list);
    }

    @PutMapping
    public AjaxResult edit(@RequestBody Bumen bumen){
       return toAjax(bumenService.edit(bumen));
    }

    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(bumenService.delete(ids));
    }
}
